/*******************************************************************************

  Paying Outsourced Labor: Direct Evidence from Linked Temp Agency-Worker-Client Data

  By Andres Drenik, Simon Jäger, Pascuel Plotkin and Benjamin Schoefer
	January 7th, 2021
  
	DESCRIPTION: Calculates size of connected set

*******************************************************************************/




/********************************************************************************
***** Preliminaries
********************************************************************************/
set more off
cap log close
local curr_date = c(current_date)
log using "${logs}/15_Auxiliary_Connected_Set`curr_date'", replace


/****************************************************************************************
* Load Dataset
****************************************************************************************/

use "${intermediate_data_emp}/AKM_Firm_FE_for_export_stata.dta", clear

/****************************************************************************************
* Calculate size of Largest Connected Set
****************************************************************************************/

sum firm_id
global total_firms = r(N)
sum firm_id if connected_set == 1
global firms_connected = r(N)
global perc_firms_connect = (${firms_connected} / ${total_firms})*100
display("The percentage of firms that are in the connected set is: ${perc_firms_connect}")

sum firm_id [fw=obs]
global total_obs = r(N)
sum firm_id [fw=obs] if connected_set == 1
global obs_connected = r(N)
global perc_obs_connect = (${obs_connected} / ${total_obs})*100
display("The percentage of observations that are in the connected set is: ${perc_obs_connect}")

log close
